using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Menu : MonoBehaviour
{
    GameObject g;
    private int Id = 0;
    public static int button;

    void Start()
    {
        SceneManager.scene = "Menu";

        g = new GameObject("B_Iniciar", typeof(B_Iniciar));
        g.GetComponent<B_Iniciar>();
        g.tag = "B_Iniciar";

        g = new GameObject("B_Creditos", typeof(B_Creditos));
        g.GetComponent<B_Creditos>();
        g.tag = "B_Creditos";

        g = new GameObject("B_Instrucoes", typeof(B_Instrucoes));
        g.GetComponent<B_Instrucoes>();
        g.tag = "B_Instrucoes";

        this.gameObject.AddComponent("MeshRenderer");
        this.gameObject.AddComponent("MeshFilter");
        this.gameObject.AddComponent("BoxCollider");

        this.transform.position = new Vector3(0, 0, 0);
        Mesh mesh = Quad.Create(1.5f, 1);

        this.gameObject.GetComponent<MeshFilter>().mesh = mesh;
        this.gameObject.GetComponent<MeshRenderer>().material = AtlasManager.globalMaterial;
        this.gameObject.GetComponent<MeshFilter>().mesh.uv = new Vector2[]
		{
			new Vector2(AtlasManager.rects[Id].xMin, AtlasManager.rects[Id].yMax),
			new Vector2(AtlasManager.rects[Id].xMax, AtlasManager.rects[Id].yMax),
			new Vector2(AtlasManager.rects[Id].xMax, AtlasManager.rects[Id].yMin),
			new Vector2(AtlasManager.rects[Id].xMin, AtlasManager.rects[Id].yMin)
		};
    }

    void Update()
    {
		if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            button = 1;
            SceneManager.Change();
        }

        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            button = 2;
            SceneManager.Change();
        }

        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            button = 3;
            SceneManager.Change();
        }
	}
}